package cn.wenhaha.lazy;

/**
 * @ClassName: LazyTwo
 * @description: TODO 懒汉单例，第二个改进方法
 * @author: wyndem
 * @date: 2019/5/13 12:43
 * @Version: 1.0
 **/
public class LazyTwo {

    private static LazyTwo lazeTwo;

    private LazyTwo() {
    }

    /**
     * description: 首次加载会阻塞，后面创建好对象后就不会被阻塞，是线程安全的
     * @Author wyndem
     * @Date 2019/5/13 12:49
     * @Param []
     * @return cn.wenhaha.lazy.LazyTwo
     **/
    public static LazyTwo getInstance(){
        if (lazeTwo==null){
            synchronized (LazyTwo.class){
                if (lazeTwo==null)
                    lazeTwo=new LazyTwo();
            }
        }
        return lazeTwo;
    }

}
